Skip to content

ext/intl: Reset IntlChar error state on method entry - #22500

Closed
kn1g78 wants to merge 2 commits into
php:PHP-8.4from
kn1g78:intlchar-reset-error
Closed

ext/intl: Reset IntlChar error state on method entry#22500
kn1g78 wants to merge 2 commits into
php:PHP-8.4from
kn1g78:intlchar-reset-error

Conversation

@kn1g78

@kn1g78 kn1g78 commented Jun 28, 2026

Copy link
Copy Markdown
Contributor

IntlChar methods did not reset the global intl error state on entry.

Because of that, a successful call could still leave intl_get_error_code() and
intl_get_error_message() reporting an error from a previous failed IntlChar
call.

This adds the reset at method entry and a PHPT covering a failed
IntlChar::digit() call followed by a successful IntlChar::forDigit() call.

@LamentXU123 LamentXU123 left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Mostly looks correct. This should target php-8.4 as a bug fix similar to #22119
You should also write NEWS file.

Comment thread ext/intl/uchar/uchar.cpp Outdated
@kn1g78
kn1g78 force-pushed the intlchar-reset-error branch 4 times, most recently from edf320b to 650a371 Compare June 29, 2026 10:13
@kn1g78
kn1g78 marked this pull request as ready for review June 29, 2026 10:14
@kn1g78
kn1g78 requested a review from devnexen as a code owner June 29, 2026 10:14
Comment thread ext/intl/uchar/uchar.cpp Outdated
@kn1g78
kn1g78 force-pushed the intlchar-reset-error branch from 650a371 to 4866f16 Compare June 29, 2026 10:41
@kn1g78
kn1g78 force-pushed the intlchar-reset-error branch from 4866f16 to 7d6f8ce Compare June 29, 2026 10:46
@kn1g78
kn1g78 changed the base branch from master to PHP-8.4 June 29, 2026 10:46
LamentXU123 added a commit that referenced this pull request Jun 29, 2026
* PHP-8.5:

  ext/intl: Reset IntlChar error state on method entry (#22500)
pull Bot pushed a commit to KornaPhp/php-src that referenced this pull request Jun 29, 2026
* PHP-8.4:

  ext/intl: Reset IntlChar error state on method entry (php#22500)
LamentXU123 added a commit that referenced this pull request Aug 2, 2026
Introduce PHP_INTL_FUNCTION_WITH_ERROR_RESET macro to standardize
and automate the global Intl error state reset at the start of
every userland PHP_FUNCTION. Also change the IC_METHOD function
to automatically reset error state in the start of the defined function.

The macro wraps the function entry point, performs
intl_error_reset(NULL), and delegates the actual logic to a
separate _impl function. This reduces boilerplate and prevents
bugs caused by missing error resets, as seen in GH-22931 and
GH-22500.

This refactor applies to all functions with a manual reset call
and does not affect internal helper functions that handle errors
independently.
adrian-enspired pushed a commit to adrian-enspired/php-src that referenced this pull request Aug 4, 2026
IntlChar methods could leave stale global intl error state after a later successful call.

Reset the intl error state when entering each IntlChar method so successful calls report U_ZERO_ERROR.

Closes php#22500
adrian-enspired pushed a commit to adrian-enspired/php-src that referenced this pull request Aug 4, 2026
* PHP-8.4:

  ext/intl: Reset IntlChar error state on method entry (php#22500)
adrian-enspired pushed a commit to adrian-enspired/php-src that referenced this pull request Aug 4, 2026
* PHP-8.5:

  ext/intl: Reset IntlChar error state on method entry (php#22500)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants